{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import json\n",
    "import requests\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "List = []\n",
    "for t in range(1, 4):\n",
    "    url = f'https://static-data.eol.cn/www/2.0/schoolprovinceindex/detial/99/32/{t}/1.json'\n",
    "    response = requests.get(url)\n",
    "    data = json.loads(response.text)\n",
    "    if len(data) > 0 :\n",
    "        List += data['data']['item']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.DataFrame(List)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '5930',\n",
       "  'min': '396.00',\n",
       "  'average': '--',\n",
       "  'filing': '396',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '347',\n",
       "  'year': '2020'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '5770',\n",
       "  'min': '390.00',\n",
       "  'average': '--',\n",
       "  'filing': '390',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '345',\n",
       "  'year': '2019'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '6386',\n",
       "  'min': '379.00',\n",
       "  'average': '--',\n",
       "  'filing': '379',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '336',\n",
       "  'year': '2018'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '6790',\n",
       "  'min': '373.00',\n",
       "  'average': '--',\n",
       "  'filing': '373',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '331',\n",
       "  'year': '2017'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': None,\n",
       "  'min': '382.00',\n",
       "  'average': '--',\n",
       "  'filing': '382',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '353',\n",
       "  'year': '2016'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '1',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '0',\n",
       "  'min': '370.00',\n",
       "  'average': '--',\n",
       "  'filing': '370',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '344',\n",
       "  'year': '2015'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '1065',\n",
       "  'min': '393.00',\n",
       "  'average': '--',\n",
       "  'filing': '393',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '343',\n",
       "  'year': '2020'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '1181',\n",
       "  'min': '382.00',\n",
       "  'average': '--',\n",
       "  'filing': '382',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '339',\n",
       "  'year': '2019'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '1259',\n",
       "  'min': '378.00',\n",
       "  'average': '--',\n",
       "  'filing': '378',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '337',\n",
       "  'year': '2018'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '1067',\n",
       "  'min': '374.00',\n",
       "  'average': '--',\n",
       "  'filing': '374',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '333',\n",
       "  'year': '2017'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': None,\n",
       "  'min': '381.00',\n",
       "  'average': '--',\n",
       "  'filing': '381',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '355',\n",
       "  'year': '2016'},\n",
       " {'school_id': '99',\n",
       "  'province_id': '32',\n",
       "  'type': '2',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '582',\n",
       "  'max': '--',\n",
       "  'min_section': '0',\n",
       "  'min': '369.00',\n",
       "  'average': '--',\n",
       "  'filing': '369',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'AA',\n",
       "  'proscore': '342',\n",
       "  'year': '2015'}]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "List"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'1': {'school_id': '44',\n",
       "  'province_id': '32',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '586',\n",
       "  'max': '--',\n",
       "  'min_section': '8908',\n",
       "  'min': '385.00',\n",
       "  'average': '--',\n",
       "  'filing': '385',\n",
       "  'type_control': '1',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'B+B+',\n",
       "  'proscore': '345',\n",
       "  'year': '2019'},\n",
       " '2': {'school_id': '44',\n",
       "  'province_id': '32',\n",
       "  'batch': '7',\n",
       "  'zslx': '0',\n",
       "  'xclevel': '586',\n",
       "  'max': '--',\n",
       "  'min_section': '1526',\n",
       "  'min': '379.00',\n",
       "  'average': '--',\n",
       "  'filing': '379',\n",
       "  'type_control': '2',\n",
       "  'batch_control': '7',\n",
       "  'local_batch_name': '本科一批',\n",
       "  'zslx_name': '普通类',\n",
       "  'xclevel_name': 'B+B+',\n",
       "  'proscore': '339',\n",
       "  'year': '2019'}}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.loc[data['year'] == '2019'].set_index('type').T.to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "year_li = list(set(data['year']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'2020': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '8422',\n",
       "   'min': '392.00',\n",
       "   'average': '--',\n",
       "   'filing': '392',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '347',\n",
       "   'year': '2020'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '1299',\n",
       "   'min': '391.00',\n",
       "   'average': '--',\n",
       "   'filing': '391',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '343',\n",
       "   'year': '2020'}},\n",
       " '2017': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '9036',\n",
       "   'min': '369.00',\n",
       "   'average': '--',\n",
       "   'filing': '369',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '331',\n",
       "   'year': '2017'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '1374',\n",
       "   'min': '371.00',\n",
       "   'average': '--',\n",
       "   'filing': '371',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '333',\n",
       "   'year': '2017'}},\n",
       " '2016': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': None,\n",
       "   'min': '378.00',\n",
       "   'average': '--',\n",
       "   'filing': '378',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '353',\n",
       "   'year': '2016'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': None,\n",
       "   'min': '377.00',\n",
       "   'average': '--',\n",
       "   'filing': '377',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '355',\n",
       "   'year': '2016'}},\n",
       " '2019': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '8908',\n",
       "   'min': '385.00',\n",
       "   'average': '--',\n",
       "   'filing': '385',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '345',\n",
       "   'year': '2019'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '1526',\n",
       "   'min': '379.00',\n",
       "   'average': '--',\n",
       "   'filing': '379',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '339',\n",
       "   'year': '2019'}},\n",
       " '2015': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '0',\n",
       "   'min': '364.00',\n",
       "   'average': '--',\n",
       "   'filing': '364',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '344',\n",
       "   'year': '2015'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '0',\n",
       "   'min': '367.00',\n",
       "   'average': '--',\n",
       "   'filing': '367',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '342',\n",
       "   'year': '2015'}},\n",
       " '2018': {'1': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '9624',\n",
       "   'min': '374.00',\n",
       "   'average': '--',\n",
       "   'filing': '374',\n",
       "   'type_control': '1',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '336',\n",
       "   'year': '2018'},\n",
       "  '2': {'school_id': '44',\n",
       "   'province_id': '32',\n",
       "   'batch': '7',\n",
       "   'zslx': '0',\n",
       "   'xclevel': '586',\n",
       "   'max': '--',\n",
       "   'min_section': '1533',\n",
       "   'min': '376.00',\n",
       "   'average': '--',\n",
       "   'filing': '376',\n",
       "   'type_control': '2',\n",
       "   'batch_control': '7',\n",
       "   'local_batch_name': '本科一批',\n",
       "   'zslx_name': '普通类',\n",
       "   'xclevel_name': 'B+B+',\n",
       "   'proscore': '337',\n",
       "   'year': '2018'}}}"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dic = {}\n",
    "for year in year_li:\n",
    "    value= data.loc[data['year'] == year].set_index('type').T.to_dict()\n",
    "    dic[year] = value\n",
    "dic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "List = []\n",
    "\n",
    "url = f'https://static-data.eol.cn/www/2.0/schoolprovinceindex/detial/99/50/1/2.json'\n",
    "response = requests.get(url)\n",
    "data = json.loads(response.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data['data']['item'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
